package com.example.administrator.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import static com.example.administrator.myapplication.R.id.linearlayout;

public class Main2Activity extends AppCompatActivity {

    private LinearLayout linearLayout;
    private Button button;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        initView();
        initData();
        initEvent();
    }
    //第一步 创建视图
    private void initView(){
        linearLayout = (LinearLayout) findViewById(R.id.linearlayout);
        View button =(Button) findViewById(R.id.button);
    }
    //第二步 获取数据
    private void initData(){

    }
    //第三步 事件监听
    private void initEvent(){
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
             linearLayout.setBackgroundColor(getResources().getColor(R.color.colorAccent));
            }
        });

    }

}
